/**
 * Copyright 2004 Cordys R&D B.V. 
 * 
 * This file is part of the Cordys FTP Connector. 
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 package com.eibus.applicationconnector.ftp;

import com.eibus.soap.ApplicationConnector;
import com.eibus.soap.ApplicationTransaction;
import com.eibus.soap.Processor;
import com.eibus.soap.SOAPTransaction;
import com.eibus.util.logger.CordysLogger;
import com.eibus.util.logger.Severity;
import com.eibus.xml.nom.Node;
import com.eibus.xml.xpath.XPath;

/**
 * FTP Application Connector class 
 */
public class FTPHandler extends ApplicationConnector
{
	private Processor processor = null;
	public static int configurationNode = 0;
	public static final String serverFaultCode = "Server.Exception";
	public static final String clientFaultCode = "Client.Invalid";
	private static XPath configXPath = XPath.getXPathInstance("./configuration");
	private static final CordysLogger logger = CordysLogger.getCordysLogger(FTPHandler.class);
	
	@Override
	public ApplicationTransaction createTransaction(SOAPTransaction soapTransaction)
	{
		/* return the Application Transaction class */
		return new FTPTransaction(processor, soapTransaction);
	}
	
	@Override
	public void open(Processor processor)
	{
		/* Get the soap processor configuration */
		this.processor = processor;
		int configurationsNode = processor.getProcessorConfigurationNode();
		configurationNode = configXPath.firstMatch(configurationsNode, null);
		logger.log(Severity.DEBUG, "SOAP Processor configuration node: " + Node.writeToString(configurationNode, true));
	}
	
	@Override
	public void close(Processor processor)
	{
		super.close(processor);
	}
	
	@Override
	public void reset(Processor processor)
	{
		super.reset(processor);
	}
}